work=work
inc=src
OPT=-O3

LRCOBJ = $(work)/Wash.o \
	$(work)/GHGS.o \
	$(work)/macAddr.o \
	$(work)/RecvBuf.o \
	$(work)/LRCTransmiter.o \
	$(work)/LRCReceiver.o 
	
TESTBENCHOBJ = $(work)/AWGN.o \
	$(work)/Carrier.o \
	$(work)/DownInterp.o \
	$(work)/Interpolator.o \
	$(work)/NCO.o \
	$(work)/Noise.o \
	$(work)/Rcosfir.o 

testWash:$(work)/testWash
testGHGS:$(work)/testGHGS
testAddr:$(work)/testAddr
testRBUF:$(work)/testRBUF
testRecv:$(work)/testRecv
testcase1:$(work)/AWGNCase
testcase2:$(work)/MultiUserCase
source:$(work)/MultiUserSource
file:$(work)/RecvFromFile

$(work)/testWash:src/Wash.cpp
	g++ -DWASHTEST -o $(work)/testWash src/Wash.cpp

$(work)/testGHGS:src/GHGS.cpp
	g++ -DGHGSTEST -o $(work)/testGHGS src/GHGS.cpp

$(work)/testAddr:src/macAddr.cpp
	g++ -DMACADDRTEST -o $(work)/testAddr src/macAddr.cpp

$(work)/testRBUF:src/macAddr.cpp src/Wash.cpp src/GHGS.cpp src/LRCTransmiter.cpp src/RecvBuf.cpp
	g++ -DRBUFTEST -o $(work)/testRBUF src/macAddr.cpp src/Wash.cpp src/GHGS.cpp src/LRCTransmiter.cpp src/RecvBuf.cpp

$(work)/testRecv:src/macAddr.cpp src/Wash.cpp src/GHGS.cpp src/LRCTransmiter.cpp src/RecvBuf.cpp src/LRCReceiver.cpp
	g++ -O2 -DRECVTEST -o $(work)/testRecv src/macAddr.cpp src/Wash.cpp src/GHGS.cpp src/LRCTransmiter.cpp src/RecvBuf.cpp src/LRCReceiver.cpp

$(work)/Wash.o:src/Wash.cpp src/Wash.h
	g++ $(OPT) -c -o $(work)/Wash.o src/Wash.cpp 
$(work)/GHGS.o:src/GHGS.cpp src/GHGS.h
	g++ $(OPT) -c -o $(work)/GHGS.o src/GHGS.cpp 
$(work)/macAddr.o:src/macAddr.cpp src/macAddr.h
	g++ $(OPT) -c -o $(work)/macAddr.o src/macAddr.cpp 
$(work)/RecvBuf.o:src/RecvBuf.cpp src/RecvBuf.h
	g++ $(OPT) -c -o $(work)/RecvBuf.o src/RecvBuf.cpp 
$(work)/LRCTransmiter.o:src/LRCTransmiter.cpp src/LRCTransmiter.h
	g++ $(OPT) -c -o $(work)/LRCTransmiter.o src/LRCTransmiter.cpp 
$(work)/LRCReceiver.o:src/LRCReceiver.cpp src/LRCReceiver.h
	g++ $(OPT) -c -o $(work)/LRCReceiver.o src/LRCReceiver.cpp 

$(work)/AWGN.o :testbench/AWGN.cpp testbench/AWGN.h
	g++ $(OPT) -c -o $(work)/AWGN.o testbench/AWGN.cpp
$(work)/Carrier.o :testbench/Carrier.cpp testbench/Carrier.h
	g++ $(OPT) -c -o $(work)/Carrier.o testbench/Carrier.cpp
$(work)/DownInterp.o :testbench/DownInterp.cpp testbench/DownInterp.h
	g++ $(OPT) -c -o $(work)/DownInterp.o testbench/DownInterp.cpp
$(work)/Interpolator.o :testbench/Interpolator.cpp testbench/Interpolator.h
	g++ $(OPT) -c -o $(work)/Interpolator.o testbench/Interpolator.cpp
$(work)/NCO.o :testbench/NCO.cpp testbench/NCO.h
	g++ $(OPT) -c -o $(work)/NCO.o testbench/NCO.cpp
$(work)/Noise.o :testbench/Noise.cpp testbench/Noise.h
	g++ $(OPT) -c -o $(work)/Noise.o testbench/Noise.cpp
$(work)/Rcosfir.o :testbench/Rcosfir.cpp testbench/Rcosfir.h
	g++ $(OPT) -c -o $(work)/Rcosfir.o testbench/Rcosfir.cpp
$(work)/AWGNCase.o : testbench/AWGNCase.cpp 
	g++ $(OPT) -I$(inc) -c -o $(work)/AWGNCase.o testbench/AWGNCase.cpp
$(work)/MultiUserCase.o : testbench/MultiUserCase.cpp 
	g++ $(OPT) -I$(inc) -c -o $(work)/MultiUserCase.o testbench/MultiUserCase.cpp
$(work)/MultiUserSource.o : testbench/MultiUserSource.cpp 
	g++ $(OPT) -I$(inc) -c -o $(work)/MultiUserSource.o testbench/MultiUserSource.cpp
$(work)/RecvFromFile.o : testbench/RecvFromFile.cpp 
	g++ $(OPT) -I$(inc) -c -o $(work)/RecvFromFile.o testbench/RecvFromFile.cpp
	
$(work)/MultiUserCase:$(work)/MultiUserCase.o $(LRCOBJ) $(TESTBENCHOBJ)
	g++ $(OPT) -o $(work)/MultiUserCase $(work)/MultiUserCase.o $(LRCOBJ) $(TESTBENCHOBJ)	

$(work)/AWGNCase:$(work)/AWGNCase.o $(LRCOBJ) $(TESTBENCHOBJ)
	g++ $(OPT) -o $(work)/AWGNCase $(work)/AWGNCase.o $(LRCOBJ) $(TESTBENCHOBJ)	

$(work)/MultiUserSource:$(work)/MultiUserSource.o $(LRCOBJ) $(TESTBENCHOBJ)
	g++ $(OPT) -o $(work)/MultiUserSource $(work)/MultiUserSource.o $(LRCOBJ) $(TESTBENCHOBJ)	

$(work)/RecvFromFile:$(work)/RecvFromFile.o $(LRCOBJ) $(TESTBENCHOBJ)
	g++ $(OPT) -o $(work)/RecvFromFile $(work)/RecvFromFile.o $(LRCOBJ) $(TESTBENCHOBJ)	
	
clean:
	rm $(work)/* -rf
	rm src/*.bak -f
	rm *.bak -f
	rm *.stackdump -f
	rm testbench/*.bak -f
	
